import {toRefs, customRef, } from 'vue'

const useDebounceRefs = function(props: object, delay: number) {
  // const a = toRefs(props)
  for(let single in props ) {
    let timer
    return customRef((track, trigger) => {
      return {
        get() {
          track()
          return single
        },
        set(newValue: any) {
          if (timer) {
            clearTimeout(timer)
          }
          timer = setTimeout(() => {
            single = newValue
            trigger()
          }, delay)
        }
      }
    })
  }
}